<template>
  <div style="height:100%;">
    <list-page-navigation>
      <div class="box">
        <!-- <img class="title" src="../assets/tupianzhan.jpg" /> -->
        <div class="header_title">-- 图片展 --</div>
        <div class="imgList">
          <div class="imgItem" v-for="item in articles" :key="item.id" @click="handleClickZL(item)">
            <img :src="item.cover" />
            <div style="display: flex;flex-direction: column;flex: 1;justify-content: space-between;">
              <div class="title_text">{{ item.coverTitle }}</div>
              <div class="date">{{ item.createTime }}</div>
            </div>

          </div>
        </div>
      </div>
    </list-page-navigation>
  </div>
</template>
<style scoped src="../../public/css/styles.css"></style>
<script>
import ListPageNavigation from '@/components/ListPageNavigation.vue';
import { homeData1, getFLIcon, baseUrlImg, clickCount } from '@/api/index.js'
export default {
  name: 'ArticleList',
  components: {
    ListPageNavigation,
  },
  data() {
    return {
      articles: [],
      iconList: [], //分类图标
    }
  },
  mounted() {
    this.getArticlesData()
  },
  methods: {
    getArticlesData() {
      let params = {
        pageNum: 1,
        pageSize: 3
      }
      homeData1(params).then(res => {
        if (res.rows && res.rows.length > 0) {
          const dataList = res.rows
          dataList.map((item) => {
            if (item.cover) {
              item.cover = baseUrlImg + item.cover
              if (item.createTime) {
                item.createTime = item.createTime.split(' ')[0]
              }
            }
          })
          this.articles = dataList
        } else {
          this.articles = []
        }
      });
    },

    //展览图片点击
    handleClickZL(item) {
      this.clickCountFunc(item.id)
      this.$router.push({
        name: 'articlePage',
        params: item
      })
    },
    //获取分类图标
    getFLIconFunc() {
      getFLIcon({}).then(res => {
        if (res.data) {
          const dataList = res.data
          dataList.map((item) => {
            item.picture = baseUrlImg + item.picture
          })
          this.iconList = dataList
        } else {
          this.iconList = []
        }
      });
    },

    //点击统计
    clickCountFunc(typeld, typesubld) {
      let params = {
        type: 3,
        typeld
      }
      if (typesubld) {
        params['typesubld'] = typesubld
      }
      clickCount(params).then(res => {
      })
    }
  }
}
</script>
<style scoped>
.box {
  max-width: 640px;
  height: 100vh;
  background-color: #fff;
  background: url(../assets/bj.png);
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
  background-size: 100% 100%;
  padding: 0.5rem 0.4rem 0 0.4rem;
  box-sizing: border-box;
  overflow: auto;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.title {
  width: 98%;
  object-fit: contain;
  margin-left: 1%;
}

.imgList {
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
}

.imgItem {
  width: 100%;
  display: flex;
  flex-direction: row;
  /* align-items: center; */
  margin-top: 0.4rem;
  box-sizing: border-box;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed #e5e5e5;
}

.imgItem :last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.imgItem .title_text {
  font-size: 0.45rem;
  margin: 0 0.7rem;
  color: white;
}

.imgItem .date {
  font-size: 0.4rem;
  margin-top: 10px;
  color: #333;
  display: flex;
  justify-content: end;
}

.imgItem img {
  width: 40%;
  aspect-ratio: 1000/1333;
  /* object-fit: contain; */
}

.header_title {
  font-size: 0.7rem;
  color: red;
  width: 100%;
  text-align: center;
  margin-bottom: 0.2rem;
  font-weight: bold;
}

@media only screen and (min-width:640px) {
  .box {
    padding: 0.2rem;
  }

  .imgList {
    padding-top: 0.2rem;
    grid-gap: 0.1rem;
  }

  .imgItem {
    margin-top: 0.2rem;
  }

  .imgItem .title {
    font-size: 0.3rem;
    margin-left: 0.2rem;
  }

  .imgItem .date {
    font-size: 0.2rem;
  }

  .imgItem .title_text {
    font-size: 0.3rem;
    margin: 0 0.3rem;
    color: white;
  }

  .header_title {
    font-size: 0.5rem;
  }
}
</style>